<template>
  <div class="wrap">
    <x-header title="修改密码"></x-header>
    <group title="修改密码" label-width="5.5em" label-margin-right="2em" label-align="justify">
      <x-input title="旧密码"  v-model="postform.oldPassword" type="password"></x-input>
      <x-input title="新密码" v-model="postform.newPassword" type="password"></x-input>
      <x-input title="重复密码" v-model="postform.newPassword2" type="password"></x-input>
    </group>
    <x-button type="primary" action-type="button" @click.native="sure">确认</x-button>
  </div>
</template>

<script>
import { XInput, XHeader, Group, XButton } from 'vux'
import { Toast } from 'mint-ui'
import { ChangePassword } from '@/api/user'
export default {
  components: {
    XHeader,
    Group,
    XButton,
    XInput
  },
  data() {
    return {
      postform: {
        oldPassword: '',
        newPassword: '',
        newPassword2: ''
      }
    }
  },
  methods: {
    sure() {
      var _this = this
      if (this.newPassword || this.newPassword2) {
        Toast('请输入密码')
        return false
      }
      if (this.newPassword !== this.newPassword2) {
        Toast('两次密码不一致')
        return false
      }
      ChangePassword(_this.postform).then(result => {
        Toast('修改密码成功')
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.wrap{
  height: 100%;
  .vux-header{
    z-index: 2;
  }
  button.weui-btn{
    width: 80%;
    margin: 30px auto;
  }
}
</style>
